/*
ID: simplyz2
LANG: C
TASK: calfflac
*/
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<assert.h> /* void assert(int exp); */
#include<ctype.h>
#define MAX_LEN 21000
char text[MAX_LEN], fulltext[MAX_LEN];
char *pal;
int pallen;

void
solve()
{
	int len;
	char *fwd, *bkwd, *end, *p;
	pallen = 0;
	end = text + strlen(text);
	for(p=text; *p; p++) {
		for(fwd=p, bkwd=p; fwd<end && bkwd>=text && *fwd==*bkwd; fwd++, bkwd--); /* odd: middle, such as 'aba' */
		bkwd++;
		len = fwd - bkwd;
		if(len > pallen) {
			pallen = len;
			pal = bkwd;
		}
		for(fwd=p+1, bkwd=p; fwd<end && bkwd>=text && *fwd==*bkwd; fwd++, bkwd--); /* even: left middle, such as 'abba' */
		bkwd++;
		len = fwd - bkwd;
		if(len > pallen) {
			pallen = len;
			pal = bkwd;
		}
	}
}

void
output()
{
	int i, n;
	char *p; 
	n = pal - text;
	printf("%d\n", pallen);
	for(i=0, p=fulltext; *p; p++) {
		if(isalpha(*p))
			++i;
		if(i > n)
			break;
	}
	for(i=0; i<pallen && *p; p++) {
		fputc(*p, stdout);
		if(isalpha(*p))
			++i;
	}
	printf("\n");
}

int
main(int argc, char **argv)
{
	char *p, *q;
	int c;
	freopen("calfflac.in", "r", stdin);
	freopen("calfflac.out", "w", stdout);
	p = fulltext;
	q = text;
	while((c=getc(stdin)) != EOF) { /* operation on each char */
		if(isalpha(c))
			*q++ = tolower(c); 
		/* '++''s priority is higher than '*', and '++' first return 'p', than move the pointer forward */
		*p++ = c;
	}
	*p = '\0';
	*q = '\0';
	solve();
	output();
	return 0;
}
